// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
const vscode = require('vscode');
const fs = require('fs-extra');
const glob = require('glob');
const path = require('path');
// this method is called when your extension is activated
// your extension is activated the very first time the command is executed

/**
 * @param {vscode.ExtensionContext} context
 */
function activate(context) {
  glob(path.join(__dirname, './commands/*'), {}, (err, files) => {
    files.map((file) => {
      if (fs.statSync(file).isDirectory()) {
        const sign = file.split('/').slice(-1)[0];
        const command = require(file);
        console.log(sign);
        context.subscriptions.push(
          vscode.commands.registerCommand(sign, command.install)
        );
      }
      return null;
    });
  });
}

// this method is called when your extension is deactivated
function deactivate() {}

module.exports = {
  activate,
  deactivate,
};
